{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "PvsQWhRoNKd7",
        "outputId": "9d39f563-cf8e-42d1-d4da-c38b44e52cbe"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Note: you may need to restart the kernel to use updated packages.\n",
            "Name: chdb\n",
            "Version: 1.0.1\n",
            "Summary: chDB is an in-process SQL OLAP Engine powered by ClickHouse\n",
            "Home-page: https://github.com/auxten/chdb\n",
            "Author: auxten\n",
            "Author-email: auxtenwpc@gmail.com\n",
            "License: Apache-2.0\n",
            "Location: /home/Clickhouse/.venv/lib/python3.9/site-packages\n",
            "Requires: \n",
            "Required-by: \n",
            "Note: you may need to restart the kernel to use updated packages.\n"
          ]
        }
      ],
      "source": [
        "%pip install chdb matplotlib --upgrade --quiet\n",
        "%pip show chdb"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "EwbNq_JCQJTA",
        "outputId": "bd6f558b-bb30-4459-cb66-cf766b0495a8"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Note: you may need to restart the kernel to use updated packages.\n"
          ]
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "Retrieving folder list\n"
          ]
        },
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Processing file 1e4uiDpZekF60Z1qu1Vxr94-kO8HaSvju customer.parquet\n",
            "Processing file 1WXD_bHteMy82KWK96fMj0nlS_zbiFa8v lineitem.parquet\n",
            "Processing file 1hfbwUNm38zuRssX239jaC5EjcPsIJwEv nation.parquet\n",
            "Processing file 1uVfJWa1qVS8PwmwJkGU4sd4J1ODHKiSH orders.parquet\n",
            "Processing file 10caFt4cLgwxpUjA_uTGLPvN7Jc1NqPAG part.parquet\n",
            "Processing file 1sWAi4ZXJbYrCLKFFaDm7y9e0uOSqbIXO partsupp.parquet\n",
            "Processing file 13w_BWaXzyUDsCOcrAedda2VlG-QODe9a region.parquet\n",
            "Processing file 1cdaVbgCu4lHHQEobinTdCCukGBvQ31I0 supplier.parquet\n",
            "Building directory structure completed\n"
          ]
        },
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "Retrieving folder list completed\n",
            "Building directory structure\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=1e4uiDpZekF60Z1qu1Vxr94-kO8HaSvju\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/customer.parquet\n",
            "100%|██████████| 1.27M/1.27M [00:00<00:00, 2.90MB/s]\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=1WXD_bHteMy82KWK96fMj0nlS_zbiFa8v\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/lineitem.parquet\n",
            "100%|██████████| 26.4M/26.4M [00:03<00:00, 6.66MB/s]\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=1hfbwUNm38zuRssX239jaC5EjcPsIJwEv\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/nation.parquet\n",
            "100%|██████████| 2.19k/2.19k [00:00<00:00, 2.54MB/s]\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=1uVfJWa1qVS8PwmwJkGU4sd4J1ODHKiSH\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/orders.parquet\n",
            "100%|██████████| 6.07M/6.07M [00:01<00:00, 5.38MB/s]\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=10caFt4cLgwxpUjA_uTGLPvN7Jc1NqPAG\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/part.parquet\n",
            "100%|██████████| 700k/700k [00:00<00:00, 1.90MB/s]\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=1sWAi4ZXJbYrCLKFFaDm7y9e0uOSqbIXO\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/partsupp.parquet\n",
            "100%|██████████| 4.41M/4.41M [00:00<00:00, 5.01MB/s]\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=13w_BWaXzyUDsCOcrAedda2VlG-QODe9a\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/region.parquet\n",
            "100%|██████████| 1.02k/1.02k [00:00<00:00, 948kB/s]\n",
            "Downloading...\n",
            "From: https://drive.google.com/uc?id=1cdaVbgCu4lHHQEobinTdCCukGBvQ31I0\n",
            "To: /mnt/MyDrive/tpchsf0.1/tpchsf-small/supplier.parquet\n",
            "100%|██████████| 83.3k/83.3k [00:00<00:00, 506kB/s]\n",
            "Download completed\n"
          ]
        },
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "total 38008\n",
            "-rw-r--r-- 1 root root  1269475 Dec 11 11:23 customer.parquet\n",
            "-rw-r--r-- 1 root root 26361943 Dec 11 11:23 lineitem.parquet\n",
            "-rw-r--r-- 1 root root     2193 Dec 11 11:23 nation.parquet\n",
            "-rw-r--r-- 1 root root  6073297 Dec 11 11:23 orders.parquet\n",
            "-rw-r--r-- 1 root root   699744 Dec 11 11:23 part.parquet\n",
            "-rw-r--r-- 1 root root  4408800 Dec 11 11:23 partsupp.parquet\n",
            "-rw-r--r-- 1 root root     1016 Dec 11 11:23 region.parquet\n",
            "-rw-r--r-- 1 root root    83251 Dec 11 11:23 supplier.parquet\n",
            "drwxr-xr-x 2 root root     4096 Dec 11 11:31 tpchsf-small\n"
          ]
        }
      ],
      "source": [
        "# For Google Colab you can mount your Google Drive and access files from there\n",
        "# from google.colab import drive\n",
        "# drive.mount('/mnt', force_remount=True)\n",
        "\n",
        "# For local Jupyter Notebook just download it\n",
        "%pip install gdown --upgrade --quiet\n",
        "import os\n",
        "import gdown\n",
        "small_data_dir = \"/mnt/MyDrive/tpchsf0.1/\"\n",
        "gdown.download_folder(\n",
        "    url=\"https://drive.google.com/drive/folders/16Lf5nAk8SCQoUiwOBY6LRxjhtB5egxQQ\",\n",
        "    output=small_data_dir,\n",
        "    verify=True,\n",
        ")\n",
        "!ls -l /mnt/MyDrive/tpchsf0.1"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# TPCH SF queries"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 14,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Define the TPCH queries\n",
        "def get_queries(data_dir):\n",
        "    lineitem = \"file('\" + data_dir + \"lineitem.parquet')\"\n",
        "    customer = \"file('\" + data_dir + \"customer.parquet')\"\n",
        "    nation = \"file('\" + data_dir + \"nation.parquet')\"\n",
        "    orders = \"file('\" + data_dir + \"orders.parquet')\"\n",
        "    part = \"file('\" + data_dir + \"part.parquet')\"\n",
        "    partsupp = \"file('\" + data_dir + \"partsupp.parquet')\"\n",
        "    region = \"file('\" + data_dir + \"region.parquet')\"\n",
        "    supplier = \"file('\" + data_dir + \"supplier.parquet')\"\n",
        "    return [\n",
        "        # Query 1\n",
        "        f\"\"\"-- Query 1\n",
        "        SELECT   l_returnflag,\n",
        "                l_linestatus,\n",
        "                Sum(l_quantity)                                       AS sum_qty,\n",
        "                Sum(l_extendedprice)                                  AS sum_base_price,\n",
        "                Sum(l_extendedprice * (1 - l_discount))               AS sum_disc_price,\n",
        "                Sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge,\n",
        "                Avg(l_quantity)                                       AS avg_qty,\n",
        "                Avg(l_extendedprice)                                  AS avg_price,\n",
        "                Avg(l_discount)                                       AS avg_disc,\n",
        "                Count(*)                                              AS count_order\n",
        "        FROM     {lineitem}\n",
        "        WHERE    l_shipdate <= toDate('1998-12-01') - interval 90 day\n",
        "        GROUP BY l_returnflag,\n",
        "                l_linestatus\n",
        "        ORDER BY l_returnflag,\n",
        "                l_linestatus;\"\"\",\n",
        "\n",
        "        # Query 2 v2\n",
        "        f\"\"\"-- Query 2 v2\n",
        "        with cheapest_part as\n",
        "        (\n",
        "        select\n",
        "            min(ps_supplycost) as cp_lowest,\n",
        "            p_partkey as cp_partkey\n",
        "        from {part} p,\n",
        "            {partsupp} ps,\n",
        "            {supplier} s,\n",
        "            {nation} n,\n",
        "            {region} r\n",
        "        where p_partkey = ps_partkey\n",
        "            and s_suppkey = ps_suppkey\n",
        "            and s_nationkey = n_nationkey\n",
        "            and n_regionkey = r_regionkey\n",
        "            and r_name = 'EUROPE'\n",
        "        group by p_partkey\n",
        "        )\n",
        "        select\n",
        "            s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address,\n",
        "            s_phone, s_comment\n",
        "        from {part} p,\n",
        "            {supplier} s,\n",
        "            {partsupp} ps,\n",
        "            {nation} n,\n",
        "            {region} r,\n",
        "            cheapest_part cp\n",
        "        where p_partkey = ps_partkey\n",
        "            and s_suppkey = ps_suppkey\n",
        "            and p_size = 15\n",
        "            and p_type like '%BRASS'\n",
        "            and s_nationkey = n_nationkey\n",
        "            and n_regionkey = r_regionkey\n",
        "            and r_name = 'EUROPE'\n",
        "            and ps_supplycost = cp_lowest\n",
        "            and cp_partkey = p_partkey\n",
        "        order by s_acctbal desc,\n",
        "            n_name,\n",
        "            s_name,\n",
        "            p_partkey\n",
        "        limit 10;\n",
        "        \"\"\",\n",
        "\n",
        "        # Query 3\n",
        "        f\"\"\"-- Query 3\n",
        "        SELECT\n",
        "            l_orderkey,\n",
        "            sum(l_extendedprice * (1 - l_discount)) AS revenue,\n",
        "            o_orderdate,\n",
        "            o_shippriority\n",
        "        FROM\n",
        "            {customer} c,\n",
        "            {orders} o,\n",
        "            {lineitem} l\n",
        "        WHERE\n",
        "            c_mktsegment = 'BUILDING'\n",
        "            AND c_custkey = o_custkey\n",
        "            AND l_orderkey = o_orderkey\n",
        "            AND o_orderdate < toDate('1995-03-15')\n",
        "            AND l_shipdate > toDate('1995-03-15')\n",
        "        GROUP BY\n",
        "            l_orderkey,\n",
        "            o_orderdate,\n",
        "            o_shippriority\n",
        "        ORDER BY\n",
        "            revenue DESC,\n",
        "            o_orderdate\n",
        "        LIMIT 10;\"\"\",\n",
        "\n",
        "        # Query 4\n",
        "        f\"\"\"-- Query 4\n",
        "        SELECT\n",
        "            o_orderpriority,\n",
        "            count(*) AS order_count\n",
        "        FROM\n",
        "            {orders} o\n",
        "        WHERE\n",
        "            o_orderdate >= toDate('1993-07-01')\n",
        "            AND o_orderdate < toDate('1993-07-01') + INTERVAL 3 MONTH\n",
        "            AND o_orderkey in (\n",
        "                SELECT\n",
        "                    l_orderkey\n",
        "                FROM\n",
        "                    {lineitem} l\n",
        "                WHERE\n",
        "                    l_commitdate < l_receiptdate\n",
        "            )\n",
        "        GROUP BY\n",
        "            o_orderpriority\n",
        "        ORDER BY\n",
        "            o_orderpriority;\"\"\",\n",
        "\n",
        "        # Query 5\n",
        "        f\"\"\"-- Query 5\n",
        "        SELECT\n",
        "            n_name,\n",
        "            sum(l_extendedprice * (1 - l_discount)) AS revenue\n",
        "        FROM\n",
        "            {customer} c,\n",
        "            {orders} o,\n",
        "            {lineitem} l,\n",
        "            {supplier} s,\n",
        "            {nation} n,\n",
        "            {region} r\n",
        "        WHERE\n",
        "            c_custkey = o_custkey\n",
        "            AND l_orderkey = o_orderkey\n",
        "            AND l_suppkey = s_suppkey\n",
        "            AND c_nationkey = s_nationkey\n",
        "            AND s_nationkey = n_nationkey\n",
        "            AND n_regionkey = r_regionkey\n",
        "            AND r_name = 'ASIA'\n",
        "            AND o_orderdate >= toDate('1994-01-01')\n",
        "            AND o_orderdate < toDate('1994-01-01') + INTERVAL 1 YEAR\n",
        "        GROUP BY\n",
        "            n_name\n",
        "        ORDER BY\n",
        "            revenue DESC;\"\"\",\n",
        "\n",
        "        # Query 6\n",
        "        f\"\"\"-- Query 6\n",
        "        SELECT\n",
        "            sum(l_extendedprice * l_discount) AS revenue\n",
        "        FROM\n",
        "            {lineitem} l\n",
        "        WHERE\n",
        "            l_shipdate >= toDate('1994-01-01')\n",
        "            AND l_shipdate < toDate('1994-01-01') + INTERVAL 1 YEAR\n",
        "            AND l_discount BETWEEN 0.06 - 0.01 AND 0.06 + 0.01\n",
        "            AND l_quantity < 24;\"\"\",\n",
        "\n",
        "        # Query 7\n",
        "        f\"\"\"-- Query 7\n",
        "        SELECT\n",
        "            supp_nation,\n",
        "            cust_nation,\n",
        "            l_year,\n",
        "            sum(volume) AS revenue\n",
        "        FROM\n",
        "            (\n",
        "                SELECT\n",
        "                    n1.n_name AS supp_nation,\n",
        "                    n2.n_name AS cust_nation,\n",
        "                    toYear(l_shipdate) AS l_year,\n",
        "                    l_extendedprice * (1 - l_discount) AS volume\n",
        "                FROM\n",
        "                    {supplier} s,\n",
        "                    {lineitem} l,\n",
        "                    {orders} o,\n",
        "                    {customer} c,\n",
        "                    {nation} n1,\n",
        "                    {nation} n2\n",
        "                WHERE\n",
        "                    s_suppkey = l_suppkey\n",
        "                    AND o_orderkey = l_orderkey\n",
        "                    AND c_custkey = o_custkey\n",
        "                    AND s_nationkey = n1.n_nationkey\n",
        "                    AND c_nationkey = n2.n_nationkey\n",
        "                    AND (\n",
        "                        (n1.n_name = 'FRANCE' AND n2.n_name = 'GERMANY')\n",
        "                        or (n1.n_name = 'GERMANY' AND n2.n_name = 'FRANCE')\n",
        "                    )\n",
        "                    AND l_shipdate BETWEEN toDate('1995-01-01') AND toDate('1996-12-31')\n",
        "            ) AS shipping\n",
        "        GROUP BY\n",
        "            supp_nation,\n",
        "            cust_nation,\n",
        "            l_year\n",
        "        ORDER BY\n",
        "            supp_nation,\n",
        "            cust_nation,\n",
        "            l_year;\"\"\",\n",
        "\n",
        "        # Query 8\n",
        "        f\"\"\"-- Query 8\n",
        "        SELECT\n",
        "            o_year,\n",
        "            sum(CASE\n",
        "                WHEN nation = 'BRAZIL' THEN volume\n",
        "                ELSE 0\n",
        "            END) / sum(volume) AS mkt_share\n",
        "        FROM\n",
        "            (\n",
        "                SELECT\n",
        "                    toYear(o_orderdate) AS o_year,\n",
        "                    l_extendedprice * (1 - l_discount) AS volume,\n",
        "                    n2.n_name AS nation\n",
        "                FROM\n",
        "                    {part} p,\n",
        "                    {supplier} s,\n",
        "                    {lineitem} l,\n",
        "                    {orders} o,\n",
        "                    {customer} c,\n",
        "                    {nation} n1,\n",
        "                    {nation} n2,\n",
        "                    {region} r\n",
        "                WHERE\n",
        "                    p_partkey = l_partkey\n",
        "                    AND s_suppkey = l_suppkey\n",
        "                    AND l_orderkey = o_orderkey\n",
        "                    AND o_custkey = c_custkey\n",
        "                    AND c_nationkey = n1.n_nationkey\n",
        "                    AND n1.n_regionkey = r_regionkey\n",
        "                    AND r_name = 'AMERICA'\n",
        "                    AND s_nationkey = n2.n_nationkey\n",
        "                    AND o_orderdate BETWEEN toDate('1995-01-01') AND toDate('1996-12-31')\n",
        "                    AND p_type = 'ECONOMY ANODIZED STEEL'\n",
        "            ) AS all_nations\n",
        "        GROUP BY\n",
        "            o_year\n",
        "        ORDER BY\n",
        "            o_year;\"\"\",\n",
        "\n",
        "        # Query 9\n",
        "        f\"\"\"-- Query 9\n",
        "        SELECT\n",
        "            nation,\n",
        "            o_year,\n",
        "            sum(amount) AS sum_profit\n",
        "        FROM\n",
        "            (\n",
        "                SELECT\n",
        "                    n_name AS nation,\n",
        "                    toYear(o_orderdate) AS o_year,\n",
        "                    l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity AS amount\n",
        "                FROM\n",
        "                    {part} p,\n",
        "                    {supplier} s,\n",
        "                    {lineitem} l,\n",
        "                    {partsupp} ps,\n",
        "                    {orders} o,\n",
        "                    {nation} n\n",
        "                WHERE\n",
        "                    s_suppkey = l_suppkey\n",
        "                    AND ps_suppkey = l_suppkey\n",
        "                    AND ps_partkey = l_partkey\n",
        "                    AND p_partkey = l_partkey\n",
        "                    AND o_orderkey = l_orderkey\n",
        "                    AND s_nationkey = n_nationkey\n",
        "                    AND p_name LIKE '%green%'\n",
        "            ) AS profit\n",
        "        GROUP BY\n",
        "            nation,\n",
        "            o_year\n",
        "        ORDER BY\n",
        "            nation,\n",
        "            o_year DESC;\"\"\",\n",
        "\n",
        "        # Query 10\n",
        "        f\"\"\"-- Query 10\n",
        "        SELECT\n",
        "            c_custkey,\n",
        "            c_name,\n",
        "            sum(l_extendedprice * (1 - l_discount)) AS revenue,\n",
        "            c_acctbal,\n",
        "            n_name,\n",
        "            c_address,\n",
        "            c_phone,\n",
        "            c_comment\n",
        "        FROM\n",
        "            {customer} c,\n",
        "            {orders} o,\n",
        "            {lineitem} l,\n",
        "            {nation} n\n",
        "        WHERE\n",
        "            c_custkey = o_custkey\n",
        "            AND l_orderkey = o_orderkey\n",
        "            AND o_orderdate >= toDate('1993-10-01')\n",
        "            AND o_orderdate < toDate('1993-10-01') + INTERVAL 3 MONTH\n",
        "            AND l_returnflag = 'R'\n",
        "            AND c_nationkey = n_nationkey\n",
        "        GROUP BY\n",
        "            c_custkey,\n",
        "            c_name,\n",
        "            c_acctbal,\n",
        "            c_phone,\n",
        "            n_name,\n",
        "            c_address,\n",
        "            c_comment\n",
        "        ORDER BY\n",
        "            revenue DESC\n",
        "        LIMIT 20;\"\"\",\n",
        "\n",
        "        # Query 11\n",
        "        f\"\"\"-- Query 11\n",
        "        SELECT\n",
        "            ps_partkey,\n",
        "            sum(ps_supplycost * ps_availqty::float) AS value\n",
        "        FROM\n",
        "            {partsupp} ps,\n",
        "            {supplier} s,\n",
        "            {nation} n\n",
        "        WHERE\n",
        "            ps_suppkey = s_suppkey\n",
        "            AND s_nationkey = n_nationkey\n",
        "            AND n_name = 'GERMANY'\n",
        "        GROUP BY\n",
        "            ps_partkey\n",
        "        HAVING\n",
        "            sum(ps_supplycost * ps_availqty::float) > (\n",
        "                SELECT\n",
        "                    sum(ps_supplycost * ps_availqty::float) * 0.0001\n",
        "                FROM\n",
        "                    {partsupp} ps,\n",
        "                    {supplier} s,\n",
        "                    {nation} n\n",
        "                WHERE\n",
        "                    ps_suppkey = s_suppkey\n",
        "                    AND s_nationkey = n_nationkey\n",
        "                    AND n_name = 'GERMANY'\n",
        "            )\n",
        "        ORDER BY\n",
        "            value DESC;\"\"\",\n",
        "\n",
        "        # Query 12\n",
        "        f\"\"\"-- Query 12\n",
        "        SELECT\n",
        "            l_shipmode,\n",
        "            sum(CASE\n",
        "                WHEN o_orderpriority = '1-URGENT'\n",
        "                    or o_orderpriority = '2-HIGH'\n",
        "                    THEN 1\n",
        "                ELSE 0\n",
        "            END) AS high_line_count,\n",
        "            sum(CASE\n",
        "                WHEN o_orderpriority <> '1-URGENT'\n",
        "                    AND o_orderpriority <> '2-HIGH'\n",
        "                    THEN 1\n",
        "                ELSE 0\n",
        "            END) AS low_line_count\n",
        "        FROM\n",
        "            {orders} o,\n",
        "            {lineitem} l\n",
        "        WHERE\n",
        "            o_orderkey = l_orderkey\n",
        "            AND l_shipmode IN ('MAIL', 'SHIP')\n",
        "            AND l_commitdate < l_receiptdate\n",
        "            AND l_shipdate < l_commitdate\n",
        "            AND l_receiptdate >= toDate('1994-01-01')\n",
        "            AND l_receiptdate < toDate('1994-01-01') + INTERVAL 1 YEAR\n",
        "        GROUP BY\n",
        "            l_shipmode\n",
        "        ORDER BY\n",
        "            l_shipmode;\"\"\",\n",
        "\n",
        "        # Query 13\n",
        "        f\"\"\"-- Query 13\n",
        "        SELECT\n",
        "            c_count,\n",
        "            count(*) AS custdist\n",
        "        FROM\n",
        "            (\n",
        "                SELECT\n",
        "                    c_custkey,\n",
        "                    count(o_orderkey) AS c_count\n",
        "                FROM\n",
        "                    {customer} AS c\n",
        "                    LEFT JOIN {orders} AS o ON c_custkey = o_custkey AND o_comment NOT LIKE '%special%requests%'\n",
        "                GROUP BY\n",
        "                    c_custkey\n",
        "            ) AS c_orders\n",
        "        GROUP BY\n",
        "            c_count\n",
        "        ORDER BY\n",
        "            custdist DESC,\n",
        "            c_count DESC;\"\"\",\n",
        "\n",
        "        # Query 14\n",
        "        f\"\"\"-- Query 14\n",
        "        SELECT\n",
        "            100.00 * sum(CASE\n",
        "                WHEN p_type LIKE 'PROMO%'\n",
        "                    THEN l_extendedprice * (1 - l_discount)\n",
        "                ELSE 0\n",
        "            END) / sum(l_extendedprice * (1 - l_discount)) AS promo_revenue\n",
        "        FROM\n",
        "            {lineitem} l,\n",
        "            {part} p\n",
        "        WHERE\n",
        "            l_partkey = p_partkey\n",
        "            AND l_shipdate >= toDate('1995-09-01')\n",
        "            AND l_shipdate < toDate('1995-09-01') + INTERVAL 1 MONTH;\"\"\",\n",
        "\n",
        "        # Query 15\n",
        "        f\"\"\"-- Query 15\n",
        "        SELECT\n",
        "            s_suppkey,\n",
        "            s_name,\n",
        "            s_address,\n",
        "            s_phone,\n",
        "            total_revenue\n",
        "        FROM\n",
        "            {supplier} s,\n",
        "            (\n",
        "                SELECT\n",
        "                    l_suppkey AS supplier_no,\n",
        "                    sum(l_extendedprice * (1 - l_discount)) AS total_revenue\n",
        "                FROM\n",
        "                    {lineitem} l\n",
        "                WHERE\n",
        "                    l_shipdate >= toDate('1996-01-01')\n",
        "                    AND l_shipdate < toDate('1996-01-01') + INTERVAL 3 MONTH\n",
        "                GROUP BY\n",
        "                    l_suppkey\n",
        "            ) revenue0\n",
        "        WHERE\n",
        "            s_suppkey = supplier_no\n",
        "            AND abs(total_revenue - (\n",
        "                    SELECT\n",
        "                        max(total_revenue)\n",
        "                    FROM\n",
        "                        (\n",
        "                            SELECT\n",
        "                                l_suppkey AS supplier_no,\n",
        "                                sum(l_extendedprice * (1 - l_discount)) AS total_revenue\n",
        "                            FROM\n",
        "                                {lineitem} l\n",
        "                            WHERE\n",
        "                                l_shipdate >= toDate('1996-01-01')\n",
        "                                AND l_shipdate < toDate('1996-01-01') + INTERVAL 3 MONTH\n",
        "                            GROUP BY\n",
        "                                l_suppkey\n",
        "                        ) revenue1\n",
        "            )) < 0.001\n",
        "        ORDER BY\n",
        "            s_suppkey;\"\"\",\n",
        "\n",
        "        # Query 16\n",
        "        f\"\"\"-- Query 16\n",
        "        SELECT\n",
        "            p_brand,\n",
        "            p_type,\n",
        "            p_size,\n",
        "            count(DISTINCT ps_suppkey) AS supplier_cnt\n",
        "        FROM\n",
        "            {partsupp} ps,\n",
        "            {part} p\n",
        "        WHERE\n",
        "            p_partkey = ps_partkey\n",
        "            AND p_brand <> 'Brand#45'\n",
        "            AND p_type NOT LIKE 'MEDIUM POLISHED%'\n",
        "            AND p_size IN (49, 14, 23, 45, 19, 3, 36, 9)\n",
        "            AND ps_suppkey NOT IN (\n",
        "                SELECT\n",
        "                    s_suppkey\n",
        "                FROM\n",
        "                    {supplier} s\n",
        "                WHERE\n",
        "                    s_comment LIKE '%Customer%Complaints%'\n",
        "            )\n",
        "        GROUP BY\n",
        "            p_brand,\n",
        "            p_type,\n",
        "            p_size\n",
        "        ORDER BY\n",
        "            supplier_cnt DESC,\n",
        "            p_brand,\n",
        "            p_type,\n",
        "            p_size;\"\"\",\n",
        "\n",
        "        # Query 17\n",
        "        f\"\"\"-- Query 17\n",
        "        SELECT\n",
        "            sum(l_extendedprice) / 7.0 AS avg_yearly\n",
        "        FROM\n",
        "            {lineitem} l,\n",
        "            {part} p,\n",
        "            (\n",
        "                SELECT\n",
        "                    l_partkey AS lpk,\n",
        "                    0.2 * avg(l_quantity) AS avg_qty\n",
        "                FROM\n",
        "                    {lineitem} l\n",
        "                GROUP BY\n",
        "                    l_partkey\n",
        "            ) AS tmp\n",
        "        WHERE\n",
        "            p_partkey = l_partkey\n",
        "            AND p_partkey = lpk\n",
        "            AND p_brand = 'Brand#23'\n",
        "            AND p_container = 'MED BOX'\n",
        "            AND l_quantity < avg_qty;\"\"\",\n",
        "\n",
        "        # Query 18\n",
        "        f\"\"\"-- Query 18\n",
        "        SELECT\n",
        "            c_name,\n",
        "            c_custkey,\n",
        "            o_orderkey,\n",
        "            o_orderdate,\n",
        "            o_totalprice,\n",
        "            sum(l_quantity)\n",
        "        FROM\n",
        "            {customer} c,\n",
        "            {orders} o,\n",
        "            {lineitem} l\n",
        "        WHERE\n",
        "            o_orderkey IN (\n",
        "                SELECT\n",
        "                    l_orderkey\n",
        "                FROM\n",
        "                    {lineitem} l\n",
        "                GROUP BY\n",
        "                    l_orderkey\n",
        "                HAVING\n",
        "                    sum(l_quantity) > 300\n",
        "            )\n",
        "            AND c_custkey = o_custkey\n",
        "            AND o_orderkey = l_orderkey\n",
        "        GROUP BY\n",
        "            c_name,\n",
        "            c_custkey,\n",
        "            o_orderkey,\n",
        "            o_orderdate,\n",
        "            o_totalprice\n",
        "        ORDER BY\n",
        "            o_totalprice DESC,\n",
        "            o_orderdate\n",
        "        LIMIT 100;\"\"\",\n",
        "\n",
        "        # Query 19\n",
        "        f\"\"\"-- Query 19\n",
        "        SELECT\n",
        "            sum(l_extendedprice * (1 - l_discount)) AS revenue\n",
        "        FROM\n",
        "            {lineitem} l JOIN {part} p\n",
        "            ON p_partkey = l_partkey\n",
        "        WHERE\n",
        "            (\n",
        "                p_brand = 'Brand#12'\n",
        "                AND p_container IN ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')\n",
        "                AND l_quantity >= 1 AND l_quantity <= 1 + 10\n",
        "                AND p_size BETWEEN 1 AND 5\n",
        "                AND l_shipmode IN ('AIR', 'AIR REG')\n",
        "                AND l_shipinstruct = 'DELIVER IN PERSON'\n",
        "            )\n",
        "            OR\n",
        "            (\n",
        "                p_brand = 'Brand#23'\n",
        "                AND p_container IN ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')\n",
        "                AND l_quantity >= 10 AND l_quantity <= 10 + 10\n",
        "                AND p_size BETWEEN 1 AND 10\n",
        "                AND l_shipmode IN ('AIR', 'AIR REG')\n",
        "                AND l_shipinstruct = 'DELIVER IN PERSON'\n",
        "            )\n",
        "            OR\n",
        "            (\n",
        "                p_brand = 'Brand#34'\n",
        "                AND p_container IN ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')\n",
        "                AND l_quantity >= 20 AND l_quantity <= 20 + 10\n",
        "                AND p_size BETWEEN 1 AND 15\n",
        "                AND l_shipmode IN ('AIR', 'AIR REG')\n",
        "                AND l_shipinstruct = 'DELIVER IN PERSON'\n",
        "            );\"\"\",\n",
        "\n",
        "        # Query 20\n",
        "        f\"\"\"-- Query 20\n",
        "        WITH avail_part_supp\n",
        "            AS (SELECT 0.5 * SUM(l_quantity) AS ps_halfqty,\n",
        "                        l_partkey             AS pkey,\n",
        "                        l_suppkey             AS skey\n",
        "                FROM   {lineitem}\n",
        "                WHERE  l_shipdate >= DATE '1994-01-01'\n",
        "                        AND l_shipdate < DATE '1994-01-01' + interval '1' year\n",
        "                GROUP  BY pkey,\n",
        "                        skey)\n",
        "        SELECT s_name,\n",
        "            s_address\n",
        "        FROM {supplier} s,\n",
        "            {nation} n\n",
        "        WHERE  s_suppkey IN (SELECT ps_suppkey\n",
        "                            FROM   {partsupp} ps,\n",
        "                                    avail_part_supp\n",
        "                            WHERE  ps_partkey IN (SELECT p_partkey\n",
        "                                                FROM   {part} p\n",
        "                                                WHERE  p_name LIKE 'forest%')\n",
        "                                    AND ps_partkey = pkey\n",
        "                                    AND ps_suppkey = skey\n",
        "                                    AND ps_availqty > ps_halfqty)\n",
        "            AND s_nationkey = n_nationkey\n",
        "            AND n_name = 'CANADA'\n",
        "        ORDER  BY s_name;\"\"\",\n",
        "\n",
        "        # Query 21\n",
        "        f\"\"\"-- Query 21\n",
        "        SELECT\n",
        "        s_name,\n",
        "        Count(*) AS numwait\n",
        "        FROM {supplier} s,\n",
        "            {lineitem} l1,\n",
        "            {orders} o,\n",
        "            {nation} n\n",
        "        WHERE  s_suppkey = l1.l_suppkey\n",
        "            AND o_orderkey = l1.l_orderkey\n",
        "            AND o_orderstatus = 'F'\n",
        "            AND l1.l_receiptdate > l1.l_commitdate\n",
        "            AND l1.l_orderkey IN (SELECT l_orderkey\n",
        "                                    FROM {lineitem} l\n",
        "                                    GROUP  BY l_orderkey\n",
        "                                    HAVING Count(l_suppkey) > 1)\n",
        "            AND l1.l_orderkey NOT IN (SELECT l_orderkey\n",
        "                                        FROM   {lineitem} l\n",
        "                                        WHERE  l_receiptdate > l_commitdate\n",
        "                                        GROUP  BY l_orderkey\n",
        "                                        HAVING Count(l_suppkey) > 1)\n",
        "            AND s_nationkey = n_nationkey\n",
        "            AND n_name = 'SAUDI ARABIA'\n",
        "        GROUP  BY s_name\n",
        "        ORDER  BY numwait DESC,\n",
        "                s_name\n",
        "        LIMIT  100; \"\"\",\n",
        "\n",
        "        # Query 22\n",
        "        f\"\"\"-- Query 22\n",
        "        SELECT\n",
        "        --Query22\n",
        "        cntrycode,\n",
        "        Count(*)       AS numcust,\n",
        "        Sum(c_acctbal) AS totacctbal\n",
        "        FROM   (SELECT Substring(c_phone FROM 1 FOR 2) AS cntrycode,\n",
        "                    c_acctbal\n",
        "                FROM   {customer} c\n",
        "                WHERE  Substring(c_phone FROM 1 FOR 2) IN ( '13', '31', '23', '29',\n",
        "                                                            '30', '18', '17' )\n",
        "                    AND c_acctbal > toDecimal64((SELECT Avg(c_acctbal)\n",
        "                                                    FROM   {customer} c\n",
        "                                                    WHERE  c_acctbal > 0\n",
        "                                                        AND Substring(c_phone FROM 1\n",
        "                                                                        FOR 2)\n",
        "                                                            IN (\n",
        "                                                            '13', '31', '23', '29',\n",
        "                                                            '30', '18', '17' )), 2)\n",
        "                    AND c_custkey NOT IN (SELECT o_custkey\n",
        "                                            FROM   {orders} o)) AS custsale\n",
        "        GROUP  BY cntrycode\n",
        "        ORDER  BY cntrycode;\"\"\",\n",
        "    ]\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {},
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Query 1 execution time: 0.1577291488647461 seconds\n",
            "\"A\",\"F\",3774200,5320753880.69,5054096266.6828,5256751331.449234,25.537587116854997,36002.12382901414,0.05014459706340077,147790\n",
            "\"N\",\"F\",95257,133737795.84,127132372.6512,132286291.229445,25.30066401062417,35521.32691633466,0.04939442231075697,3765\n",
            "\"N\",\"O\",7459297,10512270008.9,9986238338.3847,10385578376.585467,25.545537671232875,36000.9246880137,0.05009595890410959,292000\n",
            "\"R\",\"F\",3785523,5337950526.47,5071818532.942,5274405503.049367,25.5259438574251,35994.029214030925,0.04998927856184382,148301\n",
            "\n",
            "#############################################\n",
            "Query 2 execution time: 0.21104145050048828 seconds\n",
            "9828.21,\"Supplier#000000647\",\"UNITED KINGDOM\",13120,\"Manufacturer#5\",\"vV6Teq1EvLlR\",\"33-258-202-4782\",\"mong the carefully quiet accounts slee\"\n",
            "9508.37,\"Supplier#000000070\",\"FRANCE\",3563,\"Manufacturer#1\",\"jd4djZv0cc5KdnA0q9oOqvceaPUbNloOW\",\"16-821-608-1166\",\"n instructions are about the ironic, ironic excuses. instructions cajol\"\n",
            "9508.37,\"Supplier#000000070\",\"FRANCE\",17268,\"Manufacturer#4\",\"jd4djZv0cc5KdnA0q9oOqvceaPUbNloOW\",\"16-821-608-1166\",\"n instructions are about the ironic, ironic excuses. instructions cajol\"\n",
            "9453.01,\"Supplier#000000802\",\"ROMANIA\",10021,\"Manufacturer#5\",\"1Uj23QWxQjj7EyeqHWqGWTbN\",\"29-342-882-6463\",\"s according to the even deposits integrate express packages. express\"\n",
            "9453.01,\"Supplier#000000802\",\"ROMANIA\",13275,\"Manufacturer#4\",\"1Uj23QWxQjj7EyeqHWqGWTbN\",\"29-342-882-6463\",\"s according to the even deposits integrate express packages. express\"\n",
            "9192.1,\"Supplier#000000115\",\"UNITED KINGDOM\",13325,\"Manufacturer#1\",\"EhrYy0MT5M1vfZ0V4skpifdp6pgFz5\",\"33-597-248-1220\",\"onic instructions. ironic, regular deposits haggle f\"\n",
            "9032.15,\"Supplier#000000959\",\"GERMANY\",4958,\"Manufacturer#4\",\"TK qrnjpDvd1Jc\",\"17-108-642-3106\",\"nag across the slyly even pin\"\n",
            "8702.02,\"Supplier#000000333\",\"RUSSIA\",11810,\"Manufacturer#3\",\"fQ5Lr4KvbNHI3WDMhkcI S6xYtgIi1k\",\"32-508-202-6136\",\"ounts around the requests cajole furiously blithely even instructions. slyly\"\n",
            "8615.5,\"Supplier#000000812\",\"FRANCE\",10551,\"Manufacturer#2\",\"TAJWyNst8OGVPINgqtzwyyp002iYNDVub\",\"16-585-724-6633\",\"ress ideas eat quickly. blithely express deposits was slyly. final, \"\n",
            "8615.5,\"Supplier#000000812\",\"FRANCE\",13811,\"Manufacturer#4\",\"TAJWyNst8OGVPINgqtzwyyp002iYNDVub\",\"16-585-724-6633\",\"ress ideas eat quickly. blithely express deposits was slyly. final, \"\n",
            "#############################################\n",
            "Query 3 execution time: 0.12056207656860352 seconds\n",
            "223140,355369.0698,\"1995-03-14\",0\n",
            "584291,354494.7318,\"1995-02-21\",0\n",
            "405063,353125.4577,\"1995-03-03\",0\n",
            "573861,351238.277,\"1995-03-09\",0\n",
            "554757,349181.7426,\"1995-03-14\",0\n",
            "506021,321075.581,\"1995-03-10\",0\n",
            "121604,318576.4154,\"1995-03-07\",0\n",
            "108514,314967.0754,\"1995-02-20\",0\n",
            "462502,312604.542,\"1995-03-08\",0\n",
            "178727,309728.9306,\"1995-02-25\",0\n",
            "#############################################\n",
            "Query 4 execution time: 0.1292574405670166 seconds\n",
            "\"1-URGENT\",999\n",
            "\"2-HIGH\",997\n",
            "\"3-MEDIUM\",1031\n",
            "\"4-NOT SPECIFIED\",989\n",
            "\"5-LOW\",1077\n",
            "\n",
            "#############################################\n",
            "Query 5 execution time: 0.23753905296325684 seconds\n",
            "\"CHINA\",7822103\n",
            "\"INDIA\",6376121.5085\n",
            "\"JAPAN\",6000077.2184\n",
            "\"INDONESIA\",5580475.4027\n",
            "\"VIETNAM\",4497840.5466\n",
            "\n",
            "#############################################\n",
            "Query 6 execution time: 0.07625746726989746 seconds\n",
            "7115406.7008\n",
            "\n",
            "#############################################\n",
            "Query 7 execution time: 0.36234521865844727 seconds\n",
            "\"FRANCE\",\"GERMANY\",1995,4637235.1501\n",
            "\"FRANCE\",\"GERMANY\",1996,5224779.5736\n",
            "\"GERMANY\",\"FRANCE\",1995,6232818.7037\n",
            "\"GERMANY\",\"FRANCE\",1996,5557312.1121\n",
            "\n",
            "#############################################\n",
            "Query 8 execution time: 0.2825889587402344 seconds\n",
            "1995,0.0286\n",
            "1996,0.0182\n",
            "\n",
            "#############################################\n",
            "Query 9 execution time: 0.3643314838409424 seconds\n",
            "\"ALGERIA\",1998,2321785.3682\n",
            "\"ALGERIA\",1997,3685016.8589\n",
            "\"ALGERIA\",1996,4276597.4253\n",
            "\"ALGERIA\",1995,4418370.4154\n",
            "\"ALGERIA\",1994,3864849.9521\n",
            "\"ALGERIA\",1993,3541051.3865\n",
            "\"ALGERIA\",1992,4310013.3482\n",
            "\"ARGENTINA\",1998,2685983.8005\n",
            "\"ARGENTINA\",1997,4242147.8124\n",
            "\"ARGENTINA\",1996,3907867.0103\n",
            "#############################################\n",
            "Query 10 execution time: 0.16109991073608398 seconds\n",
            "8242,\"Customer#000008242\",622786.7297,6322.09,\"ETHIOPIA\",\"cYDWDiJt06B8CYzXX2L8x2hn1VFG\",\"15-792-676-1184\",\" regular theodolites affix. carefully ironic packages cajole deposits; slyly ironic packages wake quickly. regular,\"\n",
            "7714,\"Customer#000007714\",557400.3053,9799.98,\"IRAN\",\"9DDikq08GEE4B3X\",\"20-922-418-6024\",\"even accounts should cajole. regular, regular\"\n",
            "11032,\"Customer#000011032\",512500.9641,8496.93,\"UNITED KINGDOM\",\"5igjoUgXoDUZVUIectL5lXO1T3AGKza0ft\",\"33-102-772-3533\",\"uests. ironic accounts after the fluffily fi\"\n",
            "2455,\"Customer#000002455\",481592.4053,2070.99,\"GERMANY\",\"a5DZ199yfAcFhfi2uwBE PKo,Z\",\"17-946-225-9977\",\"pinto beans alongside of the furiously ironic asymptotes are quickly even platelets: express\"\n",
            "12106,\"Customer#000012106\",479414.2133,5342.11,\"UNITED STATES\",\"wyJXywcExUxt\",\"34-905-346-4472\",\"blithely blithely final attainments? carefully special pinto beans around the quickly even asymptote\"\n",
            "8530,\"Customer#000008530\",457855.9467,9734.95,\"MOROCCO\",\"leatyNRWCnfTMnTNuDGHsWJjRuAX\",\"25-736-932-5850\",\" the carefully pending packages. carefully \"\n",
            "13984,\"Customer#000013984\",446316.5104,3482.28,\"IRAN\",\"B13vxRBojwvP3\",\"20-981-264-2952\",\"egular, ironic accounts integrate sly\"\n",
            "1966,\"Customer#000001966\",444059.0382,1937.72,\"ALGERIA\",\"IbwZr7j QVifqf9WizOIWx,UXV9CqxUyrwj\",\"10-973-269-8886\",\"odolites across the unusual accounts hang carefully furiously bold excuses. regular pi\"\n",
            "11026,\"Customer#000011026\",417913.4142,7738.76,\"ALGERIA\",\"4C iGzChcqnhGBdeeu\",\"10-184-163-4632\",\"eposits cajole according to the furiously bold instructions. regular, regular dependencies wake carefully eve\"\n",
            "8501,\"Customer#000008501\",412797.51,6906.7,\"ARGENTINA\",\"UTUQLX cQrF1UUJPsz\",\"11-317-552-5840\",\" packages. pending Tiresias after the regularly express forges haggle fina\"\n",
            "#############################################\n",
            "Query 11 execution time: 0.13345789909362793 seconds\n",
            "12098,16227681.21\n",
            "5134,15709338.52\n",
            "13334,15023662.41\n",
            "17052,14351644.200000001\n",
            "3452,14070870.14\n",
            "12552,13332469.18\n",
            "1084,13170428.29\n",
            "5797,13038622.72\n",
            "12633,12892561.61\n",
            "403,12856217.34\n",
            "#############################################\n",
            "Query 12 execution time: 0.10709404945373535 seconds\n",
            "\"MAIL\",647,945\n",
            "\"SHIP\",620,943\n",
            "\n",
            "#############################################\n",
            "Query 13 execution time: 0.14435386657714844 seconds\n",
            "0,5000\n",
            "9,659\n",
            "10,658\n",
            "11,643\n",
            "8,555\n",
            "12,542\n",
            "13,508\n",
            "7,494\n",
            "19,471\n",
            "20,464\n",
            "#############################################\n",
            "Query 14 execution time: 0.08095574378967285 seconds\n",
            "16.283855689005982\n",
            "\n",
            "#############################################\n",
            "Query 15 execution time: 0.12838053703308105 seconds\n",
            "677,\"Supplier#000000677\",\"TEJ LMkTnY5hp8aQckzyb\",\"23-290-639-3315\",1614410.2928\n",
            "\n",
            "#############################################\n",
            "Query 16 execution time: 0.07068777084350586 seconds\n",
            "\"Brand#14\",\"SMALL ANODIZED NICKEL\",45,12\n",
            "\"Brand#22\",\"SMALL BURNISHED BRASS\",19,12\n",
            "\"Brand#25\",\"PROMO POLISHED COPPER\",14,12\n",
            "\"Brand#35\",\"LARGE ANODIZED STEEL\",45,12\n",
            "\"Brand#35\",\"PROMO BRUSHED COPPER\",9,12\n",
            "\"Brand#51\",\"ECONOMY ANODIZED STEEL\",9,12\n",
            "\"Brand#53\",\"LARGE BRUSHED NICKEL\",45,12\n",
            "\"Brand#11\",\"ECONOMY POLISHED COPPER\",14,8\n",
            "\"Brand#11\",\"LARGE PLATED STEEL\",23,8\n",
            "\"Brand#11\",\"PROMO POLISHED STEEL\",23,8\n",
            "#############################################\n",
            "Query 17 execution time: 0.11968088150024414 seconds\n",
            "23512.752857142856\n",
            "\n",
            "#############################################\n",
            "Query 18 execution time: 0.18635177612304688 seconds\n",
            "\"Customer#000001639\",1639,502886,\"1994-04-12\",456423.88,312\n",
            "\"Customer#000006655\",6655,29158,\"1995-10-21\",452805.02,305\n",
            "\"Customer#000014110\",14110,565574,\"1995-09-24\",425099.85,301\n",
            "\"Customer#000001775\",1775,6882,\"1997-04-09\",408368.1,303\n",
            "\"Customer#000011459\",11459,551136,\"1993-05-19\",386812.74,308\n",
            "\n",
            "#############################################\n",
            "Query 19 execution time: 0.15020322799682617 seconds\n",
            "168597.286\n",
            "\n",
            "#############################################\n",
            "Query 20 execution time: 0.13359642028808594 seconds\n",
            "\"Supplier#000000157\",\"1EmkCApL5iF\"\n",
            "\"Supplier#000000197\",\"3oYqODDUGH3XsHXmPuzYHW5NLU3,ONZl\"\n",
            "\"Supplier#000000287\",\"UQR8bUA4V2HxVbw9K\"\n",
            "\"Supplier#000000378\",\"mLPJtpu4wOc cSFzBR\"\n",
            "\"Supplier#000000530\",\"0BvoewCPg2scOEfuL93FRKqSxHmdhw1\"\n",
            "\"Supplier#000000555\",\"8Lp0QWPLFXrJrX1sTWkAEdzUsh5ke\"\n",
            "\"Supplier#000000557\",\"IH,v63JRgXMkVhJOJ Gxur0W\"\n",
            "\"Supplier#000000729\",\"CAOGYCBtTVT7aB1p6qHbxF6VVhXaHLgTpI\"\n",
            "\"Supplier#000000935\",\"JHRSOterYgt4MTNo7cupTzA,6MoNw 4\"\n",
            "\n",
            "#############################################\n",
            "Query 21 execution time: 0.33342695236206055 seconds\n",
            "\"Supplier#000000445\",16\n",
            "\"Supplier#000000825\",16\n",
            "\"Supplier#000000709\",15\n",
            "\"Supplier#000000762\",15\n",
            "\"Supplier#000000357\",14\n",
            "\"Supplier#000000399\",14\n",
            "\"Supplier#000000496\",14\n",
            "\"Supplier#000000977\",13\n",
            "\"Supplier#000000144\",12\n",
            "\"Supplier#000000188\",12\n",
            "#############################################\n",
            "Query 22 execution time: 0.08685183525085449 seconds\n",
            "\"13\",94,714035.05\n",
            "\"17\",96,722560.15\n",
            "\"18\",99,738012.52\n",
            "\"23\",93,708285.25\n",
            "\"29\",85,632693.46\n",
            "\"30\",87,646748.02\n",
            "\"31\",87,647372.5\n",
            "\n",
            "#############################################\n"
          ]
        }
      ],
      "source": [
        "import time\n",
        "import chdb\n",
        "\n",
        "queries = get_queries(small_data_dir)\n",
        "\n",
        "\n",
        "times = []\n",
        "# Run each query and record the time of each query cost\n",
        "for i, query in enumerate(queries):\n",
        "    # Start the timer\n",
        "    start_time = time.time()\n",
        "\n",
        "    # Run the query\n",
        "    ret = chdb.query(query, \"CSV\")\n",
        "\n",
        "    # Calculate the query execution time\n",
        "    end_time = time.time()\n",
        "    execution_time = end_time - start_time\n",
        "    times.append(execution_time)\n",
        "    print(f\"Query {i+1} execution time: {execution_time} seconds\")\n",
        "    # max 10 lines of str(ret)\n",
        "    lines = str(ret).split(\"\\n\")\n",
        "    print(\"\\n\".join(lines[:10]))\n",
        "    print(\"#############################################\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Plot the execution time of the queries"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 32,
      "metadata": {},
      "outputs": [
        {
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bEFVdcES+88EKsWLEi6urqYuTIkdG3b98YMWJEC50mAAAA5EbGn/EePXp0vPPOOzFp0qSor6+PysrKmDNnTuMCaitXroxWrT7s88cff3z84Ac/iKuvvjq+8Y1vRL9+/eLxxx+Pv/u7v4uIiMLCwnjllVfivvvui40bN0Z5eXkMHz48brjhhigqKmqh0wQAAIDcyGpxtQkTJjResf6oefPmfWzfueeeG+eee26z49u2bRtPP/10NjEAAAAg72X8VnMAAABg7yneAAAAkCLFGwAAAFKkeAMAAECKFG8AAABIkeINAAAAKVK8AQAAIEWKNwAAAKRI8QYAAIAUKd4AAACQIsUbAAAAUqR4AwAAQIoUbwAAAEiR4g0AAAApUrwBAAAgRYo3AAAApEjxBgAAgBQp3gAAAJAixRsAAABSpHgDAABAihRvAAAASJHiDQAAAClSvAEAACBFijcAAACkSPEGAACAFCneAAAAkCLFGwAAAFKkeAMAAECKFG8AAABIkeINAAAAKVK8AQAAIEWKNwAAAKRI8QYAAIAUKd4AAACQIsUbAAAAUqR4AwAAQIoUbwAAAEiR4g0AAAApUrwBAAAgRYo3AAAApEjxBgAAgBQp3gAAAJAixRsAAABSpHgDAABAihRvAAAASJHiDQAAAClSvAEAACBFijcAAACkSPEGAACAFCneAAAAkKKsivfMmTOjoqIiiouLY+jQobFw4cJPHP/II49E//79o7i4OAYOHBhPPfVUk9uTJIlJkyZF9+7do23btlFVVRVLly7NJhoAAADklYyL98MPPxy1tbUxefLkWLRoURxzzDExYsSIWLduXbPjf/WrX8WYMWPioosuisWLF8eoUaNi1KhR8eqrrzaOuemmm+K2226LWbNmxYIFC6J9+/YxYsSIeP/997M/MwAAAMgDrTO9w/Tp02P8+PFRU1MTERGzZs2KJ598MmbPnh1XXXXVx8bfeuutUV1dHVdccUVERNxwww0xd+7cuOOOO2LWrFmRJEnMmDEjrr766hg5cmRERNx///1RWloajz/+eJx//vkfm3P79u2xffv2xq83bdoUERGbN2/O9HRyYtf2bTk79l/7HuVrtnzNFSHbnhyo2fI1V4RseyJbd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VfGwIEDo3379lFeXh5jx46NNWvW5DxbRMS1114b/fv3j/bt20fnzp2jqqoqFixYkBfZ/tLFF18cBQUFMWPGjJznuvDCC6OgoKDJVl1dnWquvc0WEbFkyZI488wzo1OnTtG+ffv43Oc+FytXrsx5to9+z3ZvN998c86zbdmyJSZMmBCHHXZYtG3bNgYMGBCzZs3Kea6Ghoa48MILo7y8PNq1axfV1dWxdOnSnGTZm8fY999/P/71X/81Dj300OjQoUOcc8450dDQkBfZ7rrrrjjllFOiY8eOUVBQEBs3bsx5rnfffTf+z//5P3HkkUdG27Zt4/DDD4+vfOUrsWnTppxni4j48pe/HH369Im2bdtG165dY+TIkfHaa6/lRbbdkiSJ008/PQoKCuLxxx/Pi2ynnHLKxx7nLr744pznioiYP39+/P3f/320b98+OnbsGCeddFL88Y9/zGm2FStW7PH54ZFHHslptoiI+vr6+Od//ucoKyuL9u3bx7HHHhv/7//9v6xztWS25cuXx1lnnRVdu3aNjh07xnnnnZf6Y+7evq59991344ILLoiOHTvGIYccEhdddFFs2bIl57n+7d/+LY4//vho165dHHLIIVnnaelsK1asiIsuuih69eoVbdu2jT59+sTkyZNjx44dLZIxXyneeeaNN96IIUOGxNKlS+PBBx+MZcuWxaxZs6Kuri6GDRsW7777bkREbN26NU444YS48cYb8yrbtm3bYtGiRXHNNdfEokWL4tFHH43XX389zjzzzJxni4j4zGc+E3fccUf85je/ieeffz4qKipi+PDh8c477+Q8226PPfZYvPDCC1FeXp5apkxzVVdXx9q1axu3Bx98MC+yLV++PE444YTo379/zJs3L1555ZW45pprori4OOfZ/vL7tXbt2pg9e3YUFBTEOeeck/NstbW1MWfOnPje974XS5YsicsvvzwmTJgQTzzxRM5yJUkSo0aNijfeeCN+/OMfx+LFi+OII46Iqqqq2Lp1637NErF3j7Ff/epX47/+67/ikUceieeeey7WrFkTZ599dl5k27ZtW1RXV8c3vvGNrPO0dK41a9bEmjVrYtq0afHqq6/Gd7/73ZgzZ05cdNFFOc8WETF48OC49957Y8mSJfH0009HkiQxfPjw2LlzZ86z7TZjxowoKCjIKk+a2caPH9/k8e6mm27Kea758+dHdXV1DB8+PBYuXBi//vWvY8KECdGqVXYvfVsqW8+ePT/2/HDddddFhw4d4vTTT89ptoiIsWPHxuuvvx5PPPFE/OY3v4mzzz47zjvvvFi8eHFOs23dujWGDx8eBQUF8cwzz8Qvf/nL2LFjR3zxi1+MXbt2pZZtb1/XXnDBBfHb3/425s6dGz/5yU/i5z//eXzpS1/Kea4dO3bEueeeG5dccklWWdLK9tprr8WuXbviP/7jP+K3v/1t3HLLLTFr1qwWec7Kawl5pbq6OjnssMOSbdu2Ndm/du3apF27dsnFF1/cZP+bb76ZRESyePHivMu228KFC5OISN566628y7Zp06YkIpKf/exneZFt9erVSY8ePZJXX301OeKII5Jbbrkl57nGjRuXjBw5MrUc+5Jt9OjRyT/90z/lZbaPGjlyZPL3f//3eZHt6KOPTq6//vomY4499tjkm9/8Zs5yvf7660lEJK+++mrj7Tt37ky6du2a3H333fs1y1/a02Psxo0bk4MOOih55JFHGvctWbIkiYhk/vz5Oc32l5599tkkIpI//OEPWWVKK9duP/zhD5M2bdokH3zwQd5l+5//+Z8kIpJly5blRbbFixcnPXr0SNauXZtERPLYY49llauls5188snJZZddlnWWtHINHTo0ufrqq1skV0tn+6jKysrkX/7lX/IiW/v27ZP777+/yb4uXbpk/TjcUtmefvrppFWrVsmmTZsa923cuDEpKChI5s6du1+y7fbR17W/+93vkohIfv3rXzeO+elPf5oUFBQkb7/9ds5y/aV777036dSpU8ZZ9ke23W666aakV69e+5wxnyneeWTDhg1JQUFB8u///u/N3j5+/Pikc+fOya5duxr37a/inU223ebOnZsUFBQ0ebDMh2zbt29Pbr755qRTp07JO++8k/NsO3fuTL7whS8kM2bMSJIkSbV4Z5Jr3LhxSadOnZKuXbsmn/nMZ5KLL744Wb9+fSq5Msn2pz/9KenQoUNy/fXXJ8OHD0+6du2aHHfccfv0YrSlsn3071p9fX3SunXr5Pvf/35eZBs/fnwyZMiQZPXq1cmuXbuSZ555JunQoUPy3HPP5SzXK6+80mzJOeyww5Jx48bt1yx78xhbV1fXbKE9/PDDk+nTp+c021/a1+Kd9vPS3XffnZSUlORdti1btiSXX3550qtXr2T79u05z7Z169bkqKOOSh5//PEkSZJ9Kt4tne3kk09OSkpKkkMPPTQ5+uijk6uuuirZunVrTnM1NDQkEZHcdtttybBhw5Ju3bolJ510UvKLX/wi41wtne2jXnzxxSQikl/+8pd5ke20005LzjjjjGTDhg3Jzp07kwcffDBp165dsnTp0pxme+KJJ5LCwsLk/fffb9z3/vvvJ4WFhcnkyZP3S7bdPvq69p577kkOOeSQJmM++OCDpLCwMHn00UdzlusvtUTxTrsLfPOb30wGDx68Txnznbea55GlS5dGkiRx1FFHNXv7UUcdFX/4wx9SfVv0nmSb7f33348rr7wyxowZEx07dsyLbD/5yU+iQ4cOUVxcHLfcckvMnTs3SkpKcp7txhtvjNatW8dXvvKVVLJkm6u6ujruv//+qKurixtvvDGee+65OP3007N++2VLZXv77bdjy5YtMXXq1Kiuro7//u//jrPOOivOPvvseO6553Ka7aP/Du677744+OCD9+ltyC2Z7fbbb48BAwbEYYcdFm3atInq6uqYOXNmnHTSSTnL1a1btzj88MNj4sSJ8Yc//CF27NgRN954Y6xevTrWrl27X7PszWNsfX19tGnT5mOfmSstLY36+vqcZmtJaeZav3593HDDDVm/HTONbN/5zneiQ4cO0aFDh/jpT38ac+fOjTZt2uQ821e/+tU4/vjjY+TIkRlnSTvbP/7jP8b3vve9ePbZZ2PixInxwAMPxD/90z/lNNcbb7wREX9e12X8+PExZ86cOPbYY+PUU0/Nat2INP8d3HPPPXHUUUfF8ccfn/F908j2wx/+MD744IM49NBDo6ioKL785S/HY489Fn379s1pts9//vPRvn37uPLKK2Pbtm2xdevW+NrXvhY7d+7M6jmiJV/X1tfXR7du3ZqMa926dXTp0iXj54NP0+vtTLItW7Ysbr/99vjyl7/c4rnzSetcB+DjkiT5xNuzeRHQUjLJ9sEHH8R5550XSZLEnXfemXa0vc72hS98IV5++eVYv3593H333XHeeefFggULPvaguT+zrVq1Km699dZYtGhRi3x+b2/tzffs/PPPb/x64MCBMWjQoOjTp0/MmzcvTj311Jxla936zw9fI0eOjK9+9asREVFZWRm/+tWvYtasWXHyySfnLNtH/43Onj07LrjgglQ/e77b3mS7/fbb44UXXognnngijjjiiPj5z38e//qv/xrl5eVRVVWVk1xFRUXx6KOPxkUXXRRdunSJwsLCqKqqitNPP/2v3relsxwoj7H7U0vn2rx5c5xxxhkxYMCAuPbaa/chWctmu+CCC+K0006LtWvXxrRp0+K8886LX/7yl1n/222JbE888UQ888wzWX/Gdk9a6vv2lz84GThwYHTv3j1OPfXUWL58efTp0ycnuXZ/5vfLX/5y1NTURETEZz/72airq4vZs2fHlClTMs7VUtn+0h//+Mf4wQ9+ENdcc01Wef5SS2W75pprYuPGjfGzn/0sSkpK4vHHH4/zzjsvfvGLX8TAgQNzlq1r167xyCOPxCWXXBK33XZbtGrVKsaMGRPHHnts1p/bzzTb/nxdm6+5Ilo+29tvvx3V1dVx7rnnxvjx41s0a75xxTuP9O3bNwoKCmLJkiXN3r5kyZLo2rVri61KmIlMs+3+h/bWW2/F3LlzU/vpWzbZ2rdvH3379o3Pf/7zcc8990Tr1q3jnnvuyWm2X/ziF7Fu3bo4/PDDo3Xr1tG6det466234v/+3/8bFRUVOcvV3N+13r17R0lJSSxbtqzFc2WSraSkJFq3bh0DBgxocvtRRx2V2qrm2XzffvGLX8Trr78e//t//+9UMmWaraioKL7xjW/E9OnT44tf/GIMGjQoJkyYEKNHj45p06blLNchhxwSgwcPjpdffjk2btwYa9eujTlz5sSGDRuid+/e+z3LX1NWVhY7duz42GrhDQ0NUVZWltNsLSmNXO+9915UV1fHwQcfHI899lgcdNBBeZOtU6dO0a9fvzjppJPiRz/6Ubz22mvx2GOP5TTbM888E8uXL49DDjmk8fkhIuKcc86JU045JafZmjN06NCIiIyfI1oyV/fu3SMiWuz5Ia3v2Y9+9KPYtm1bjB07NuNMaWRbvnx53HHHHTF79uw49dRT45hjjonJkyfHkCFDYubMmTnNFhExfPjwWL58eaxbty7Wr18fDzzwQLz99ttZPUe05OvasrKyWLduXZP7/+lPf4p333034+eDT9Pr7b3JtmbNmvjCF74Qxx9/fNx1112pZc8bLf7mdfbJ8OHDkx49euxx0YIrrriiyf79ubja3mbbsWNHMmrUqOToo49O1q1bl3quTLI1p3fv3ll9Pqgls61fvz75zW9+02QrLy9PrrzyyuS1117LWa7mrFq1KikoKEh+/OMfp5Irk2zDhg372OJqo0aNSsaMGZPzbLuNGzduv31maW+y7V5Q8Kmnnmoy5ktf+lJy2mmn5SxXc37/+98nrVq1Sp5++umcZflri6v96Ec/atz32muv7dPiamk8/rfE4motmWvTpk3J5z//+eTkk0/O6nPAaWb7qPfffz9p27Ztcu+99+Y029q1az/2/BARya233pq88cYbOc3WnOeffz6JiOR//ud/cpZr165dSXl5+ccWV6usrEwmTpyYca6WzPaXTj755OScc87JKk8a2XavtfG73/3uY/OPHz8+p9maU1dXlxQUFGT9OqmlXtfuXlztxRdfbNz39NNPZ724Whqvt1tqcbWWzLZ69eqkX79+yfnnn5/86U9/2udsBwLFO8/8/ve/T0pKSpITTzwxee6555KVK1cmP/3pT5O/+7u/SyorK5P33nsvSZI/L3CwePHi5Mknn0wiInnooYeSxYsXJ2vXrs1pth07diRnnnlmcthhhyUvv/xysnbt2sYtmwVqWjLbli1bkokTJybz589PVqxYkbz44otJTU1NUlRU1GQl5Vxka07aq5rvTa733nsv+drXvpbMnz8/efPNN5Of/exnybHHHpv069evyQInuciWJEny6KOPJgcddFBy1113JUuXLk1uv/32pLCwMOsFdFoyW5L8uWS0a9cuufPOO1PLk022k08+OTn66KOTZ599NnnjjTeSe++9NykuLk6+853v5DTXD3/4w+TZZ59Nli9fnjz++OPJEUcckZx99tk5ybI3j7EXX3xxcvjhhyfPPPNM8uKLLybDhg1Lhg0blhfZ1q5dmyxevDi5++67k4hIfv7znyeLFy9ONmzYkLNcmzZtSoYOHZoMHDgwWbZsWZP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SFl4slFffee29s2rQpvvKVr+zT6o1pkC07+ZotX3NFyJatfM2WT7nyKctH5Wu2fM0VIVu28jVbvuaKkC1bsmUuX3NF5He2fKJ4AwAAQIr8SAIAAABSpHgDAABAihRvAAAASJHiDQAAAClSvAEAACBFijcAAACkSPEGAACAFCneAAAAkCLFGwAAAFL0/wHaKiNUV23HrAAAAABJRU5ErkJggg==",
            "text/plain": [
              "<Figure size 1200x600 with 1 Axes>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "from matplotlib import pyplot as plt\n",
        "\n",
        "# Increase the figure width\n",
        "plt.figure(figsize=(12, 6))\n",
        "\n",
        "# Plot the query execution time in bar chart\n",
        "plt.bar([\"Q\"+str(i+1) for i in range(len(times))], times)\n",
        "plt.show()\n"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.9.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
